package DataBase;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;








public class UpdateItemsOfSupplier {
	
	Vector<Vector> updates ;
	int status=0;
	
	


	public UpdateItemsOfSupplier (Vector<Vector> upd )
	{
		this.updates=upd;
	}
	
	
	
	public void updateItems()
	{
		
		SQLConnection sc=new SQLConnection();
		
		try {

			PreparedStatement ps2 = sc.getConnection().prepareStatement("UPDATE  supplier_item SET suppItemPrice=?  WHERE iid =? AND suppId=?;");	
					
			sc.getConnection().setAutoCommit(false);
			
			for(int i=0;i<updates.size();i++)
			{
								
				ps2.setString(2,(String) updates.get(i).get(0));
				ps2.setString(3,(String) updates.get(i).get(1));
				ps2.setString(1,(String) updates.get(i).get(2));
				ps2.executeUpdate();
			}
			
			sc.getConnection().commit();
			status=1;
			ps2.close();
			sc.getConnection().close();

		}
		catch (SQLException e) {
			status=0;
			e.printStackTrace();
		}
		
	}

	public int getStatus() {
		return status;
	}



	public void setStatus(int status) {
		this.status = status;
	}

}
